using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using MAPDavy.Entities;

namespace MAPDavy.Repository.Mapping
{
	public class LogMap : EntityTypeConfiguration<Log>
	{
		public LogMap()
		{
			// Primary Key
			this.HasKey(t => t.Id);

			// Properties
			this.Property(t => t.Description)
				.IsRequired()
				.HasMaxLength(255);
				
			// Table & Column Mappings
			this.ToTable("Logs");
			this.Property(t => t.Id).HasColumnName("Id");
			this.Property(t => t.MatriculaId).HasColumnName("MatriculaId");
			this.Property(t => t.FileName).HasColumnName("FileName");
			this.Property(t => t.Description).HasColumnName("Description");
			this.Property(t => t.FechaReunion).HasColumnName("FechaReunion");
			this.Property(t => t.Comentario).HasColumnName("Comentario");

			// Relationships
			this.HasRequired(t => t.Matricula)
				.WithMany(t => t.Logs)
				.HasForeignKey(d => d.MatriculaId);
				
		}
	}
}

